<template>
  <view class="login-container">
    <view class="login-form">
      <view class="title">用户登录</view>
      
      <view class="input-group">
        <input 
          type="text" 
          v-model="loginForm.username" 
          placeholder="请输入用户名" 
          class="input"
          autocomplete="off"
        />
      </view>
      
      <view class="input-group">
        <input 
          type="password" 
          v-model="loginForm.password" 
          placeholder="请输入密码" 
          class="input"
          autocomplete="new-password"
        />
      </view>
      
      <button 
        class="login-btn" 
        @click="submitLogin"
      >
        登录
      </button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      loginForm: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    submitLogin() {
      if (!this.loginForm.username.trim()) {
        this.showToast('请输入用户名')
        return
      }
      if (!this.loginForm.password.trim()) {
        this.showToast('请输入密码')
        return
      }
      
      if (this.loginForm.username === 'oqh' && this.loginForm.password === '123456') {
        this.showLoading('登录中...')
        setTimeout(() => {
          this.hideLoading()
          this.showToast('登录成功', 'success')
          uni.switchTab({
            url: '/pages/tabBar/compotent/compotent'
          })
        }, 1000)
      } else {
        this.showToast('用户名或密码错误')
        this.loginForm.password = ''
      }
    },
    
    showToast(title, icon = 'none') {
      uni.showToast({
        title,
        icon,
        duration: 2000
      })
    },
    
    showLoading(title) {
      uni.showLoading({
        title,
        mask: true
      })
    },
    
    hideLoading() {
      uni.hideLoading()
    }
  }
}
</script>

<style scoped>
.login-container {
  min-height: 100vh;
  background-color: #eef2f7;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20rpx;
}

.login-form {
  width: 100%;
  max-width: 500rpx;
  background-color: #fff;
  padding: 40rpx;
  border: 1rpx solid #c9d6e0;
}

.title {
  font-size: 32rpx;
  color: #2c6ecb;
  text-align: center;
  margin-bottom: 40rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx solid #dce6f0;
}

.input-group {
  margin-bottom: 25rpx;
}

.input {
  width: 100%;
  height: 80rpx;
  padding: 0 20rpx;
  border: 1rpx solid #b8c9d9;
  font-size: 28rpx;
  box-sizing: border-box;
}
.input:focus {
  border-color: #2c6ecb;
  outline: none;
}

.login-btn {
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  background-color: #2c6ecb;
  color: #fff;
  font-size: 28rpx;
  margin-top: 10rpx;
  border: none;
}
</style>
    